﻿

//using Castle.Core;
//using Castle.MicroKernel.Facilities;

//namespace Family.Core
//{
//    public class AttributeFacility : AbstractFacility
//    {
//        protected override void Init()
//        {
//            Kernel.ComponentModelCreated += kernel_ComponentModelCreated;
//        }

//        void kernel_ComponentModelCreated(ComponentModel model)
//        {
//            var attributes = model.Implementation.GetCustomAttributes(typeof(Castle.Core.LifestyleAttribute), false);
//            if (attributes.Length > 0)
//            {
//                var attr = attributes[0] as LifestyleAttribute;
//                if (null != attr)
//                {
//                    switch (attr.Lifestyle)
//                    {
//                        case LifestyleType.PerWebRequest:
//                            model.CustomLifestyle = typeof(Family.Core.PerWebRequestLifestyleManager);
//                            model.LifestyleType = LifestyleType.Custom;
//                            break;
//                        default:
//                            break;
//                    }
//                }
//            }
//        }
//    }
//}
